import live from './live';

const state = {
  userId: '',
  openId: '',
  name: '',
  headImg: '',
  gender: '1',
  money: 0, // 喵钻余额
  hbyMoney: 0, // 红包雨摇中的钱
  freeSendGift: false, // 是否拥有免费发礼物权限
  miao_vip_splid: '', // 最近一次领取了vip头像框的liveId
  miao_vip: '', // vip头像框
  isVipHeadBoxGetted: false, // 本场活动是否领过头像框
  vipLevel: '', // vip等级
  relativeType: '1', // 男女方亲友
  currentStatus: '', // 单身、高富帅等
  deskNum: '', // 桌号,
  enterEffect: '', // 进场特效
};

const mutations = {
  setUserInfo: (state, data) => {
    state.userId = data.userId || state.userId;
    state.openId = data.openId || state.openId;
    state.name = data.name || state.name;
    state.headImg = data.headImg || state.headImg;
    state.gender = data.gender || state.gender;
    state.miao_vip_splid = data.miao_vip_splid || state.miao_vip_splid;
    state.miao_vip = data.miao_vip || state.miao_vip;
    state.vipLevel = data.vipLevel || state.vipLevel;
    state.relativeType = data.relativeType || state.relativeType;
    state.currentStatus = data.currentStatus || state.currentStatus;
    state.deskNum = data.deskNum || state.deskNum;
    state.enterEffect = data.enterEffect || state.enterEffect;
    if (live.state.liveId === state.miao_vip_splid) {
      // 本场活动已经领过vip头像框了
      state.isVipHeadBoxGetted = true;
    } else {
      state.isVipHeadBoxGetted = false;
    }
    if (parseFloat(data.money) === 0 || parseFloat(data.money)) {
      state.money = parseFloat(data.money);
    }
    if (parseFloat(data.hbyMoney) === 0 || parseFloat(data.hbyMoney)) {
      state.hbyMoney = parseFloat(data.hbyMoney);
    }
    if (data.freeSendGift === '0' || data.freeSendGift === '1') {
      if (data.freeSendGift === '0') {
        state.freeSendGift = false;
      } else if (data.freeSendGift === '1') {
        state.freeSendGift = true;
      }
    }
  },
};

const actions = {
};

export default {
  namespaced: true,
  state,
  mutations,
  actions,
};
